package com.framework.Controller;


import com.framerock.server.Response;
import com.framerock.server.WebSocketClient;
import com.framerock.baselib.CLog;
import com.framerock.baselib.Rock;
import com.framework.ACore.Controller;

import java.net.URLDecoder;
import java.net.URLEncoder;

/**
 * websocket服务端的推送
 * */
public class ControllerReim  extends Controller {



    @Override
    protected String runAction(String action) {
        if(action.equals("push"))return reimpush();
        return super.runAction(action);
    }

    //推送消息请求地址：/reim/push
    private String reimpush(){
        String atype = mRequest.get("atype");
        String bstr  = "";
        if(Rock.equals(atype, "send")){
            String data = mRequest.get("data");
            if(!Rock.isEmpt(data))bstr = WebSocketClient.push(URLDecoder.decode(data));
        }
        return Response.returnSuccess(bstr);
    }
}
